import 'package:floor/floor.dart';
import 'package:flutter_2b_client/database/dao/GoodsScratchDao.dart';
import 'package:flutter_2b_client/database/dao/GoodsScratchItemDao.dart';

import 'converter/LocalDateConverter.dart';
import 'converter/LocalDateTimeConverter.dart';
import 'entity/GoodsScratch.dart';
import 'entity/GoodsScratchItem.dart';
// #.g.dart
import 'package:sqflite/sqflite.dart' as sqflite;
import 'dart:async';
part 'AppDatabase.g.dart';



@Database(version: 1, entities: [GoodsScratch, GoodsScratchItem])
@TypeConverters([LocalDateConverter, LocalDateTimeConverter])
abstract class AppDatabase extends FloorDatabase {
  GoodsScratchDao get goodsScratchDao;

  GoodsScratchItemDao get goodsScratchItemDao;

  static AppDatabase? _appDatabase;

  // Function to initialize the database
  static Future<AppDatabase> get instance async {
    if (_appDatabase != null) {
      return _appDatabase!;
    } else {
      return await $FloorAppDatabase
          .databaseBuilder("flutter_database.db")
          .build();
    }
  }
}
